package com.ittx.dzt.meione.service;

import com.ittx.dzt.edi.dto.InventoryUploadDTO;
import com.ittx.dzt.edi.dto.PlatformApiParamDTO;
import com.ittx.dzt.edi.dto.StoreConfigDTO;
import com.ittx.dzt.meione.handler.AbstractBaseMeioneApiHandler;
import com.ittx.dzt.sys.response.Result;
import lombok.extern.slf4j.Slf4j;
import open.constant.PlatformApiConstant;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

/**
 * 同步sku库存
 * <p>
 * cy.inventory.upload.byAll
 * /erp/un/sys/stock/update/v2  库存同步-V2(更新最新库存信息。)
 * </p>
 *
 * @author wl_code@163.com
 * @version 1.0
 * @date 2025/8/29
 */
@Slf4j
@Service
public class MeioneInventoryUploadByIdService extends AbstractBaseMeioneApiHandler<InventoryUploadDTO> {
	@Override
	public String getMeioneMethod() {
		return "/erp/un/sys/stock/update/v2";
	}

	@Override
	public String getLocalApiMethod() {
		return PlatformApiConstant.InboundInterface.INVENTORY_UPLOAD_BY_ALL;
	}

	@Override
	public Result<?> doProcess(PlatformApiParamDTO platformApiParamDTO, InventoryUploadDTO uploadStoreInventoryDTO) {
		StoreConfigDTO storeConfig = platformApiParamDTO.getStoreConfig();
		Map<String, Object> params = new HashMap<>();
		params.put("businessCode", storeConfig.getStoreUniqueCode());
		params.put("launchSkuNo", uploadStoreInventoryDTO.getPlatformSpuId());
		params.put("stockNum", uploadStoreInventoryDTO.getSyncQty());
		return this.executeApi(platformApiParamDTO.getStoreConfig(), params, platformApiParamDTO.getRequestId());
	}


}
